package com.llly.controller;


import com.llly.pojo.Easybuy_product;
import com.llly.pojo.Easybuy_product_category;
import com.llly.service.ProductService;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping("/showType")
    public List<Easybuy_product_category> findAllEpcs(){
        System.out.println("9091调用三级分类商品");
        return productService.findAllEpcs();
    }

    //直接查询1/2/3级分类下商品
    @RequestMapping("/selectEpsByEpcId")
    public List<Easybuy_product> selectEpsByEpcId(@RequestParam  Integer id){return productService.selectEpsByEpcId(id);}

    @RequestMapping("/findProductByPid")
    public Easybuy_product findProductByPid(@RequestParam Integer pid){
        return productService.findProductByid(pid);
    }

    @RequestMapping("/findAllprosByEpc")
    public List<Easybuy_product> findAllprosByEpc(@RequestParam  Integer epcId){
        return productService.findAllprosByEpc(epcId);
    }

    @RequestMapping("/findpname")
    public Easybuy_product_category findpname(@RequestParam Integer id){

        return productService.findpname(id);
    }

    @RequestMapping("/showProduct")
    public List<Easybuy_product> showProduct(@RequestParam String epname){
        System.out.println("ffjpsffff"+epname);
        return productService.showProduct(epname);
    };
    //显示一级分类

    @RequestMapping("/ShowAllOne")
    public List<Easybuy_product_category> ShowAllOne(){

        return productService.ShowAllOne();
    };

    //根据一级分类显示二级分类
    //public List<Easybuy_product_category> ShowAllTwo(Integer parentId);
    @RequestMapping("/ShowAllTwo")
    public List<Easybuy_product_category> ShowAllTwo(@RequestParam Integer parentId){

        return productService.ShowAllTwo(parentId);
    };

    //根据二级分类显示三级分类
    @RequestMapping("/ShowAllThree")
    public List<Easybuy_product_category> ShowAllThree(@RequestParam Integer parentId){

        return productService.ShowAllThree(parentId);
    };
    //商品上架
    @RequestMapping("/addeasybuy")
    public int addeasybuy(@RequestBody Easybuy_product easybuy_product){
        System.out.printf("+++++++++++++++++++++"+easybuy_product);
        return productService.addeasybuy(easybuy_product);
    };
}
